/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package multi.agent.simulation.entity;

import java.io.Serializable;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Owner
 */
@Entity
@Table(name = "rutas")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Rutas.findAll", query = "SELECT r FROM Rutas r"),
    @NamedQuery(name = "Rutas.findByDesde", query = "SELECT r FROM Rutas r WHERE r.rutasPK.desde = :desde"),
    @NamedQuery(name = "Rutas.findByHasta", query = "SELECT r FROM Rutas r WHERE r.rutasPK.hasta = :hasta"),
    @NamedQuery(name = "Rutas.findByDistancia", query = "SELECT r FROM Rutas r WHERE r.distancia = :distancia"),
    @NamedQuery(name = "Rutas.findByCapacidadMaxima", query = "SELECT r FROM Rutas r WHERE r.capacidadMaxima = :capacidadMaxima"),
    @NamedQuery(name = "Rutas.findByVelocidadMaxima", query = "SELECT r FROM Rutas r WHERE r.velocidadMaxima = :velocidadMaxima")})
public class Rutas implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected RutasPK rutasPK;
    @Basic(optional = false)
    @Column(name = "distancia")
    private int distancia;
    @Basic(optional = false)
    @Column(name = "capacidad_maxima")
    private int capacidadMaxima;
    @Column(name = "velocidad_maxima")
    private Integer velocidadMaxima;
    @JoinColumn(name = "hasta", referencedColumnName = "id", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Nodo hasta;
    @JoinColumn(name = "desde", referencedColumnName = "id", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Nodo desde;

    public Rutas() {
    }

    public Rutas(RutasPK rutasPK) {
        this.rutasPK = rutasPK;
    }

    public Rutas(RutasPK rutasPK, int distancia, int capacidadMaxima) {
        this.rutasPK = rutasPK;
        this.distancia = distancia;
        this.capacidadMaxima = capacidadMaxima;
    }

    public Rutas(int desde, int hasta) {
        this.rutasPK = new RutasPK(desde, hasta);
    }

    public RutasPK getRutasPK() {
        return rutasPK;
    }

    public void setRutasPK(RutasPK rutasPK) {
        this.rutasPK = rutasPK;
    }

    public int getDistancia() {
        return distancia;
    }

    public void setDistancia(int distancia) {
        this.distancia = distancia;
    }

    public int getCapacidadMaxima() {
        return capacidadMaxima;
    }

    public void setCapacidadMaxima(int capacidadMaxima) {
        this.capacidadMaxima = capacidadMaxima;
    }

    public Integer getVelocidadMaxima() {
        return velocidadMaxima;
    }

    public void setVelocidadMaxima(Integer velocidadMaxima) {
        this.velocidadMaxima = velocidadMaxima;
    }

    public Nodo getHasta() {
        return hasta;
    }

    public void setHasta(Nodo nodo) {
        this.hasta = nodo;
    }

    public Nodo getDesde() {
        return desde;
    }

    public void setDesde(Nodo nodo1) {
        this.desde = nodo1;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (rutasPK != null ? rutasPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Rutas)) {
            return false;
        }
        Rutas other = (Rutas) object;
        if ((this.rutasPK == null && other.rutasPK != null) || (this.rutasPK != null && !this.rutasPK.equals(other.rutasPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "multi.agent.simulation.entity.Rutas[ rutasPK=" + rutasPK + " ]";
    }
    
}
